<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="routeproductbomList">
      <el-table-column label="序号" align="center" width="50px">
        <template slot-scope="scope">
          <span>{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="子项物料编码" align="center" width="150px" prop="inspectionNumber"></el-table-column>
      <el-table-column label="子项物料名称" align="center" width="110px" prop="projectCode" />-->
      <el-table-column
        label="工单编码"
        align="center"
        width="110px"
        prop="workorderCode"
      >
      </el-table-column>
      <el-table-column label="物料名称" align="center" prop="productName">
        <template slot-scope="scope">
          <span>{{ form.productName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="BOM版本" align="center" prop="bomItemCode" />
      <el-table-column label="当前流程状态" align="center" prop="flowStatus">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.workflow_status"
            :value="scope.row.flowStatus"
          />
        </template>
      </el-table-column>
      <el-table-column label="模块名称" align="center" prop="moudleName" />
      <el-table-column
        label="操作人"
        width="110px"
        align="center"
        prop="operateBy"
      />
      <el-table-column
        label="操作时间"
        width="180px"
        align="center"
        prop="operateTime"
      />
      <!-- <el-table-column label="审批结果" align="center" prop="specification" /> -->
    </el-table>
  </div>
</template>

<script>
import { workorderPushList } from "@/api/mes/pro/workorder";
// import Detail from "./details.vue";
export default {
  name: "replenishment",
  // components: { Detail },
  props: {
    routeId: null,
    productId: null,
    processId: null,
    optType: null,
    buttonType: null,
    workorderId: null,
  },
  dicts: ["mes_order_status", "workflow_status"],
  data() {
    return {
      // 遮罩层
      loading: false,
      visible: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 产品制程物料BOM表格数据
      routeproductbomList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        workorderId: null,
        productId: null,
        bomItemCode: null,
        // pageNum: 1,
        // pageSize: 10
      },
      rules: {},
      form: {},
    };
  },
  created() {
    // this.getList();
  },

  methods: {
    init(row) {
      this.visible = true;
      // this.queryParams.workorderCode = row.projectCode;
      this.queryParams.workorderId = row.workorderId;
      this.queryParams.productId = row.productId;
      this.queryParams.bomItemCode = row.bomItemCode;
      console.log(row, "====row======");
      this.form = { ...row };
      this.getList(row);
    },
    /** 查询产品制程物料BOM列表 */
    getList() {
      this.loading = true;
      workorderPushList(this.queryParams).then((res) => {
        this.routeproductbomList = res.rows || [];
        this.loading = false;
      });
    },
    //点击生成领料单中的编号展示详情
    handleView(row) {
      this.open = true;
      console.log(row, "领料单编号的row");
      this.$nextTick(() => {
        this.$refs.detailDialog.init(row);
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.recordId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    cancel() {
      this.visible = false;
      this.routeproductbomList = [];
    },
  },
};
</script>
